<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>vue</title>
    <script src='https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js'></script>
</head>

<body>
    <div id='app'>
        <navbar @event="eventt"></navbar>
        <sidebar v-show="flag"></sidebar>
    </div>
</body>
<script>
    Vue.component('navbar', {
        template: `
        <div style="background-color:red ;">
           <button @click="click">资源管理器</button>--导航栏
        </div>
        `,
        methods: {
            click() {
                console.log('zi');
                this.$emit('event','fu')
            }
        }
    });


    Vue.component('sidebar', {
        template: `
        <div style="background-color: yellowgreen;">
                <ul>
                    <li>day01</li>
                    <li>day02</li>
                    <li>day03</li>
                    <li>day04</li>
                </ul>
        </div>
        `
    })

    let vm = new Vue({
        el: '#app',
        data: {
            flag: true
        },
        methods: {
            eventt(data) {
                console.log('fu');
                this.flag = !this.flag
                console.log('收到参数' + data);
            }
        }
    });
</script>

</html>